//
//  UITextField+Tools.m
//  demo10-9
//
//  Created by xx on 15/10/12.
//  Copyright (c) 2015年 xx. All rights reserved.
//
#define kTapTag 3698

#import "UITextField+Tools.h"

@implementation UITextField (Tools)

- (void)setLeftViewAtImageName:(NSString *)imageName
{
    UIImage *image = [UIImage imageFileNamed:imageName];
    float x = 0;
    float y = 0;
    float height = image.size.height;
    float width = image.size.width + 20.0;
    UIImageView *leftView = [[UIImageView alloc]initWithImage:image];
    leftView.frame = CGRectMake(x, y, width, height);
    leftView.contentMode = UIViewContentModeScaleAspectFit;
    
    self.leftView = leftView;
    self.leftViewMode = UITextFieldViewModeAlways;
    
}
- (void)addLeftSpace:(float)space
{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, space, 30)];
    self.leftView = view;
    self.leftViewMode = UITextFieldViewModeAlways;
}

- (void)setPlaceholderColor:(UIColor *)color
{
    if (color) {
        
        [self setValue:color forKeyPath:@"_placeholderLabel.textColor"];
    }
}

- (void)setPlaceholderFont:(UIFont *)font
{
    if (font) {
        
        [self setValue:font forKeyPath:@"_placeholderLabel.font"];
        
    }
}


@end
